package com.ankiang.treeprint.fragment.util;

import android.os.Bundle;

import com.ankiang.treeprint.R;
import com.ankiang.treeprint.fragment.QDWebExplorerFragment;
import com.ankiang.treeprint.fragment.components.TRAboutFragment;
import com.ankiang.treeprint.fragment.components.TRAddresMapFragment;
import com.ankiang.treeprint.fragment.components.TRAppVersionFragment;
import com.ankiang.treeprint.fragment.components.TRBizContactFragment;
import com.ankiang.treeprint.fragment.components.TRCalculatorFragment;
import com.ankiang.treeprint.fragment.components.TRDataAnalysisFragment;
import com.ankiang.treeprint.fragment.components.TRGiftSuggestFragment;
import com.ankiang.treeprint.fragment.components.TRHistoryKnowledgeFragment;
import com.ankiang.treeprint.fragment.components.TRHomeTreeFragment;
import com.ankiang.treeprint.fragment.components.TRRedpacketDistributeFragment;
import com.ankiang.treeprint.fragment.components.TRSettingsFragment;
import com.ankiang.treeprint.fragment.components.TRShowTextFragment;
import com.ankiang.treeprint.fragment.components.TRSupportFragment;
import com.ankiang.treeprint.fragment.home.HomeController;
import com.ankiang.treeprint.view.TRConfig;

public class TRPages {

    /**
     * 显示设置页面，使用的是Controller父类
     * @param base
     */
    public static void showSettingsPage(HomeController base) {
        TRSettingsFragment fragment = new TRSettingsFragment();
        base.startFragment(fragment);
    }

    public static void showHelpPage(HomeController base) {
        QDWebExplorerFragment fragment = new QDWebExplorerFragment();

        Bundle bundle = new Bundle();
        TRConfig conf = TRConfig.getInstance();
        bundle.putString(QDWebExplorerFragment.EXTRA_URL, conf.getHelpUrl());
        bundle.putString(QDWebExplorerFragment.EXTRA_TITLE, base.V(R.string.me_func_help));
        bundle.putBoolean(QDWebExplorerFragment.EXTRA_NEED_DECODE, true);
        fragment.setArguments(bundle);
        base.startFragment(fragment);
    }


    public static void showAboutPage(HomeController base) {
        TRAboutFragment fragment = new TRAboutFragment();
        base.startFragment(fragment);
    }
    public static void showAppVersionPage(HomeController base) {
        TRAppVersionFragment fragment = new TRAppVersionFragment();
        base.startFragment(fragment);
    }
    public static void showSupportPage(HomeController base) {
        QDWebExplorerFragment fragment = new QDWebExplorerFragment();

        Bundle bundle = new Bundle();
        TRConfig conf = TRConfig.getInstance();
        bundle.putString(QDWebExplorerFragment.EXTRA_URL, conf.getSupportUrl());
        bundle.putString(QDWebExplorerFragment.EXTRA_TITLE, "赞助");
        bundle.putBoolean(QDWebExplorerFragment.EXTRA_NEED_DECODE, true);
        fragment.setArguments(bundle);
        base.startFragment(fragment);
    }
    public static void showBizContactPage(HomeController base) {
        TRBizContactFragment fragment = new TRBizContactFragment();
        base.startFragment(fragment);
    }






    /**
     * 显示数据分析页面
     */
    public static  void showAnalysisPage(HomeController base) {
        TRDataAnalysisFragment fragment = new TRDataAnalysisFragment();
        base.startFragment(fragment);
    }


    /**
     * 显示关系计算器页面
     */
    public static  void showCalculatorPage(HomeController base) {
        TRCalculatorFragment fragment = new TRCalculatorFragment();
        base.startFragment(fragment);
    }

    public static void showAddresMapPage(HomeController base) {
        TRAddresMapFragment fragment = new TRAddresMapFragment();
        base.startFragment(fragment);

    }
    public static void showRedpacketDistributePage(HomeController base) {
        TRRedpacketDistributeFragment fragment = new TRRedpacketDistributeFragment();
        base.startFragment(fragment);

    }
    public static void showGiftSuggestPage(HomeController base) {
        TRGiftSuggestFragment fragment = new TRGiftSuggestFragment();
        base.startFragment(fragment);

    }
    public static void showHistoryKnowledgePage(HomeController base) {
        TRHomeTreeFragment fragment = new TRHomeTreeFragment();
        fragment.setGroup(0);
        fragment.setCallback(o -> {
            // 示例数据，无操作
        });
        base.startFragment(fragment);

    }

    public static void showDataTextPage(HomeController base) {
        TRShowTextFragment fragment = new TRShowTextFragment();
        fragment.setOp(TRShowTextFragment.OP_SHOW_ALL);
        base.startFragment(fragment);

    }

}
